import request from '@/config/axios'
import type { Dayjs } from 'dayjs';

/** 地址簿信息 */
export interface UserAddress {
          id: number; // 地址簿ID
          userId?: number; // 用户ID
          name?: string; // 姓名
          mobile?: string; // 手机号
          address?: string; // 详细地址
          type?: boolean; // 类型（0寄件地址 1收件地址）
          isNormal?: boolean; // 默认地址（0否 1是）
  }

// 地址簿 API
export const UserAddressApi = {
  // 查询地址簿分页
  getUserAddressPage: async (params: any) => {
    return await request.get({ url: `/business/user-address/page`, params })
  },

  // 查询地址簿详情
  getUserAddress: async (id: number) => {
    return await request.get({ url: `/business/user-address/get?id=` + id })
  },

  // 新增地址簿
  createUserAddress: async (data: UserAddress) => {
    return await request.post({ url: `/business/user-address/create`, data })
  },

  // 修改地址簿
  updateUserAddress: async (data: UserAddress) => {
    return await request.put({ url: `/business/user-address/update`, data })
  },

  // 删除地址簿
  deleteUserAddress: async (id: number) => {
    return await request.delete({ url: `/business/user-address/delete?id=` + id })
  },

  /** 批量删除地址簿 */
  deleteUserAddressList: async (ids: number[]) => {
    return await request.delete({ url: `/business/user-address/delete-list?ids=${ids.join(',')}` })
  },

  // 导出地址簿 Excel
  exportUserAddress: async (params) => {
    return await request.download({ url: `/business/user-address/export-excel`, params })
  },
}